const path = require('path')
// const webpack = require('webpack')

function resolve(dir) {
	return path.join(__dirname, dir)
}
module.exports = {
	outputDir: 'dist', //输出文件目录
	assetsDir: 'static', //放置生成的静态资源 (js、css、img、fonts) 的目录
	lintOnSave: false, //保存时检查
	productionSourceMap: false, //如果你不需要生产环境的 source map，可以将其设置为 false 以加速生产环境构建
	devServer: {
		port: 8181,
		open: true,
		overlay: {
			warnings: false,
			errors: true,
		},
		proxy: {
			'/api': {
				//
				target: 'https://www.ncei.noaa.gov',
				changeOrigin: true,
				secure: true,
				ws: true,
				pathRewrite: {
					'^/api': '',
				},
			},
		},
	},
	configureWebpack: {
		// provide the app's title in webpack's name field, so that
		// it can be accessed in index.html to inject the correct title.
		name: 'vue-cesium-template',
		resolve: {
			alias: {
				'@': resolve('src'),
			},
		},
	},
	// 全局引入scss/sass文件
	chainWebpack: (config) => {
		const oneOfsMap = config.module.rule('scss').oneOfs.store
		oneOfsMap.forEach((item) => {
			item.use('sass-resources-loader')
				.loader('sass-resources-loader')
				.options({
					// Provide path to the file with resources
					// 要公用的scss的路径
					resources: './src/styles/varibles.scss',
				})
				.end()
		})
	},
	// devServer: {
	//   proxy: {
	//     '/api': {
	//       //
	//       target: 'https://www.ncdc.noaa.gov',
	//       changeOrigin: true,
	//       pathRewrite: {
	//         '^/api': ''
	//       }
	//     }
	//   }
	// }
}
